package com.leet.meituan;

import apple.laf.JRSUIUtils;

import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class DapeiSale {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.nextLine().split(" ");
        TreeMap<Long,Long> mp = new TreeMap<>();
        long a,b,c,d,e,f,g;
        a = Long.parseLong(s[0]);
        b = Long.parseLong(s[1]);
        c = Long.parseLong(s[2]);
        d = Long.parseLong(s[3]);
        e = Long.parseLong(s[4]);
        f = Long.parseLong(s[5]);
        g = Long.parseLong(s[6]);
        mp.put(e,a);
        if(e!=f){
            mp.put(f,b);
        }else mp.put(e,mp.get(e)+b);
        if(e!=g && f!=g){
            mp.put(g,c);
        }else if (e==g){
            mp.put(e,mp.get(e)+c);
        }else {
            mp.put(f,mp.get(f)+c);
        }
        int ans = 0;
        while(d!=0){
            //System.out.println(entry.getKey());
            while(mp.lastEntry().getValue().equals((long)0)||mp.lastEntry().getValue() == null) {
                mp.remove(mp.lastKey());
            }
            //System.out.println(ans);
            Map.Entry<Long, Long> entry = mp.lastEntry();
            ans += entry.getKey();
            mp.put(entry.getKey(),entry.getValue()-1);
            d--;
        }
        System.out.println(ans);
    }
}
